import { ComponentMetadata, Snippet } from '@alilc/lowcode-types';

const LawEnforcementMeta: ComponentMetadata = {
  componentName: 'LawEnforcement',
  title: '执法管理',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  group: '城站专题',
  category: '管理监控',
  priority: 0,
  npm: {
    package: 'hzdz-charts',
    version: '0.1.0',
    exportName: 'LawEnforcement',
    main: 'src/index.tsx',
    destructuring: true,
    subName: '',
  },
  configure: {
    props: [
      {
        title: '基础配置',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'title',
            title: '组件标题',
            setter: 'StringSetter',
            defaultValue: '执法管理',
          },
          {
            name: 'englishTitle',
            title: '英文标题',
            setter: 'StringSetter',
            defaultValue: 'Space Security',
          },
          {
            name: 'defaultTimeType',
            title: '默认时间类型',
            setter: {
              componentName: 'SelectSetter',
              props: {
                options: [
                  { title: '当日', value: 'daily' },
                  { title: '当月', value: 'monthly' },
                ],
              },
            },
            defaultValue: 'daily',
          },
          {
            name: 'chartImage',
            title: '中央图表图片',
            setter: 'StringSetter',
            defaultValue: 'http://localhost:8085/static/images/chengzhanzhuanti/编组91.png',
          },
        ],
      },
      {
        title: '数据配置',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'dailyData',
            title: '当日数据',
            setter: {
              componentName: 'ArraySetter',
              props: {
                itemSetter: {
                  componentName: 'ObjectSetter',
                  props: {
                    config: {
                      items: [
                        {
                          name: 'department',
                          title: '部门名称',
                          setter: 'StringSetter',
                        },
                        {
                          name: 'type',
                          title: '执法类型',
                          setter: 'StringSetter',
                        },
                        {
                          name: 'value',
                          title: '数值',
                          setter: 'NumberSetter',
                        },
                      ],
                    },
                  },
                },
              },
            },
            defaultValue: [
              { department: '公安', type: '出动警力', value: 1000 },
              { department: '城管', type: '出动警力', value: 100 },
              { department: '交警', type: '出动警力', value: 100 },
              { department: '市场监管', type: '出动警力', value: 100 },
              { department: '城管', type: '流浪乞讨', value: 100 },
              { department: '市场监管', type: '执法巡查', value: 100 },
              { department: '市场监管', type: '广告检查', value: 100 },
            ],
          },
          {
            name: 'monthlyData',
            title: '当月数据',
            setter: {
              componentName: 'ArraySetter',
              props: {
                itemSetter: {
                  componentName: 'ObjectSetter',
                  props: {
                    config: {
                      items: [
                        {
                          name: 'department',
                          title: '部门名称',
                          setter: 'StringSetter',
                        },
                        {
                          name: 'type',
                          title: '执法类型',
                          setter: 'StringSetter',
                        },
                        {
                          name: 'value',
                          title: '数值',
                          setter: 'NumberSetter',
                        },
                      ],
                    },
                  },
                },
              },
            },
            defaultValue: [
              { department: '公安', type: '出动警力', value: 30000 },
              { department: '城管', type: '出动警力', value: 3000 },
              { department: '交警', type: '出动警力', value: 3000 },
              { department: '市场监管', type: '出动警力', value: 3000 },
              { department: '城管', type: '流浪乞讨', value: 3000 },
              { department: '市场监管', type: '执法巡查', value: 3000 },
              { department: '市场监管', type: '广告检查', value: 3000 },
            ],
          },
        ],
      },
      {
        title: '事件处理',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'onClick',
            title: '点击事件',
            setter: 'FunctionSetter',
          },
          {
            name: 'onTimeTypeChange',
            title: '时间类型切换',
            setter: 'FunctionSetter',
          },
          {
            name: 'onItemClick',
            title: '点击执法项',
            setter: 'FunctionSetter',
          },
        ],
      },
      {
        title: '外观',
        display: 'block',
        type: 'group',
        items: [
          {
            name: 'style',
            title: '自定义样式',
            setter: 'StyleSetter',
          },
          {
            name: 'className',
            title: '自定义类名',
            setter: 'StringSetter',
          },
        ],
      },
    ],
    supports: {
      style: true,
      events: ['onClick', 'onTimeTypeChange', 'onItemClick'],
    },
    component: {},
  },
};

const snippets: Snippet[] = [
  {
    title: '执法管理',
    screenshot: '',
    schema: {
      componentName: 'LawEnforcement',
      props: {
        title: '执法管理',
        englishTitle: 'Space Security',
        defaultTimeType: 'daily',
        chartImage: 'http://localhost:8085/static/images/chengzhanzhuanti/编组91.png',
        dailyData: [
          { department: '公安', type: '出动警力', value: 1000 },
          { department: '城管', type: '出动警力', value: 100 },
          { department: '交警', type: '出动警力', value: 100 },
          { department: '市场监管', type: '出动警力', value: 100 },
          { department: '城管', type: '流浪乞讨', value: 100 },
          { department: '市场监管', type: '执法巡查', value: 100 },
          { department: '市场监管', type: '广告检查', value: 100 },
        ],
        monthlyData: [
          { department: '公安', type: '出动警力', value: 30000 },
          { department: '城管', type: '出动警力', value: 3000 },
          { department: '交警', type: '出动警力', value: 3000 },
          { department: '市场监管', type: '出动警力', value: 3000 },
          { department: '城管', type: '流浪乞讨', value: 3000 },
          { department: '市场监管', type: '执法巡查', value: 3000 },
          { department: '市场监管', type: '广告检查', value: 3000 },
        ],
      },
    },
  },
];

export default {
  ...LawEnforcementMeta,
  snippets,
};